<%@ page language="java" contentType="text/html; charset=utf-8"    pageEncoding="utf-8"%>
<%@include file="header.jsp"%>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.STYLE1 {
	color: #666666;
	font-weight: bold;
}
.STYLE5 {color: #666666}
.STYLE6 {
	color: #135294;
	font-weight: bold;
}
-->
</style>
<script>
	function checkValue(){
		var   patrn=/^(0|[1-9]\d*)$|^(0|[1-9]\d*)\.(\d+)$/; 
		var s = document.getElementById("price").value;
		if(patrn.exec(s)){	
					
		} else{
			alert("价格必须是数字类型");
			document.getElementById("price").focus();
			return false;
		}
		addPurchaseHistoryForm.submit();
	}
	function setValue(str){
		document.getElementById("operateType").value="update";
		document.getElementById("tijiao").value="更新";
		var keys=new Array();
		keys[0]="purchaseHistoryId";
		keys[1]="productName" ;
		keys[2]="buydate";
		keys[3]="price";
		keys[4]= "remark";
		keys[5]="serialNumber";
		keys[6]="producttype";
		var arrays = str.split("#$");
		for(var i=0;i<arrays.length;i++){
			var key = keys[i];
			if ( key != "producttype" ){
				document.getElementById( key ).value= arrays[i];
			} else {
				var slt=document.getElementById( key );
				for(var j=0;j<slt.options.length;j++)
					if(slt.options[j].value==arrays[i])
						slt.options[j].selected=true;
			}
		}
	}
</script>
<form method="post" action="addPurchaseHistory.action" id="addPurchaseHistoryForm" name="addPurchaseHistoryForm">
 <table width="95%" border="1" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" align="center">
 	<tr>
 		<td  colspan="4" background="images/bg_table.jpg" bgcolor="#ECEAE6" align="center">新增购机历史</td>
 	</tr>
	<tr bgcolor='#F1F3F5'>
 		<td width="11%">产品</td>
 		<td width="39%">
 		 <input type="text"  name="productName" id="productName"/>
 		  <select name="producttype" id="producttype">
				<option value="1">手机</option>
				<option value="2">配件</option>
		</select>
 		 
	  </td>
 		<td width="11%">日期</td> 		 
	  <td width="39%"><input type="text" name="buydate" id="buydate" /></td>
	</tr>	
	<tr>
		<td>价格</td>
		<td><input type="text" name="price"  id="price" /><font color="red">必须是数值</font></td>
		<td>备注</td>
		<td><input type="text" name="remark"  id="remark"/></td>
		  
	</tr>
	<tr>
		<td>手机串码</td>
		<td><input type="text" name="serialNumber"  id="serialNumber" /></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		  
	</tr>
	<tr>
		<td  colspan="4"    nowrap background="images/bg_table.jpg" bgcolor="#ECEAE6"  align="center">
			<input type="button" name="tijiao" id="tijiao" onclick="checkValue()"  value="新增"/>
			<input type="hidden"  name="operateType" id="operateType" value="insert"/> 
			<input type="hidden"  name="memberId" id="memberId" value="${memberId }"/> 
			<input type="hidden"  name="purchaseHistoryId" id="purchaseHistoryId" value="-1"/> 
		</td>
	</tr>
</table> 
</form>
<br/>

<div align="center">卡号${member.cardId }   ${member.name }的购买历史列表</div>
 <table width="95%"  border="0" cellpadding="3" cellspacing="2" bgcolor="#FFFFFF" align="center">
   <tr>
     <td nowrap background="images/bg_table.jpg" bgcolor="#ECEAE6">产品名称</td>
     <td nowrap background="images/bg_table.jpg" bgcolor="#ECEAE6">日期</td>
     <td nowrap background="images/bg_table.jpg" bgcolor="#ECEAE6">价格</td>
     <td nowrap background="images/bg_table.jpg" bgcolor="#ECEAE6">手机串码</td>
     <td nowrap background="images/bg_table.jpg" bgcolor="#ECEAE6">备注</td>
     <td nowrap background="images/bg_table.jpg" bgcolor="#ECEAE6">操作</td>
   </tr>
   <s:iterator value="orderhistorys">
     <tr bgcolor='#F1F3F5' onmouseover = "this.style.backgroundColor = '#FFDCB0'" onmouseout = "this.style.backgroundColor = ''" style='cursor:hand' 
     onclick="setValue('<s:property value="id"/>#$<s:property value="productName"/>#$<s:property value="buydate"/>#$<s:property value="price"/>#$<s:property value="remark"/>#$<s:property value="serialNumber"/>#$<s:property value="producttype"/>')">
       <td><s:property value="productName"/></td>
       <td><s:property value="buydate"/></td>
       <td><s:property value="price"/></td>
       <td><s:property value="serialNumber"/></td>
       <td><s:property value="remark"/></td>
       <td><a href="deletePurchaseHistory.action?memberId=<s:property value='memberId'/>&purchaseHistoryId=<s:property value='id'/>" onclick="javascript:if(confirm('确定删除该购机历史吗')) return true; else return false;">删除</a></td>
     </tr>
   </s:iterator>
      <tr>
     <td colspan="6" nowrap background="images/bg_table.jpg" bgcolor="#ECEAE6"><a href="memberList.action">返回</a></td>
 
   </tr>
</table>
 